<?php
  
     /*
      * Following code will create a new row
      * All details are read from HTTP Post Request
      */
      
     // array for JSON response
     $response = array();
      
     // check for required fields
     if (isset($_POST['place_name']) 
		&& isset($_POST['address'])) {
      
        $place_name 	= $_POST['place_name'];
		$address  		= $_POST['address'];
		//$longitude 		= $_POST['longitude']; 
		//$latitude      	= $_POST['latitude'];
		//$phone_number  	= $_POST['phone_number'];
		//$fax_number    	= $_POST['fax_number'];
		//$email         	= $_POST['email'];
		//$website       	= $_POST['website'];
		//$open_time     	= $_POST['open_time'];
		//$close_time    	= $_POST['close_time'];
		//$visa_master   	= $_POST['visa_master'];
		//$car_parking   	= $_POST['car_parking'];
		//$moto_parking  	= $_POST['moto_parking'];
		//$delivery      	= $_POST['delivery'];
		//$wifi          	= $_POST['wifi'];
		//$description   	= $_POST['description'];
		//$public        	= $_POST['public'];
		//$delete        	= $_POST['delete'];
		//$date_create   	= $_POST['date_create'];
		//$url_image     	= $_POST['url_image'];
		//$district_id   	= $_POST['district_id'];
		//$lowest_price  	= $_POST['lowest_price'];
		//$hightest_price	= $_POST['hightest_price'];
      
         // include db connect class
         require_once __DIR__ . '/db_connect.php';
      
         // connecting to db
         $db = new DB_CONNECT();
      
		$result = mysql_query("INSERT INTO `place`(`place_name`,`address`,`date_create`,`public`,`delete`)VALUES('$place_name','$address',NOW(),1,0)");
         // mysql inserting a new row
         /*$result = mysql_query("INSERT INTO `place`(`place_name`, 
													`address`, 
													`longitude`, 
													`latitude`, 
													`district_id`, 
													`phone_number`, 
													`fax_number`, 
													`email`, 
													`website`, 
													`open_time`, 
													`close_time`, 
													`lowest_price`, 
													`hightest_price`,
													`visa_master`, 
													`car_parking`, 
													`moto_parking`, 
													`delivery`, 
													`wifi`, 
													`description`, 
													`public`, 
													`delete`, 
													`date_create`, 
													`url_image`) 
												VALUES(`$place_name`, 
													`$address`, 
													`$longitude`, 
													`$latitude`, 
													`$district_id`, 
													`$phone_number`, 
													`$fax_number`, 
													`$email`, 
													`$website`, 
													`$open_time`, 
													`$close_time`,  
													`$lowest_price`, 
													`$hightest_price`,
													`$visa_master`, 
													`$car_parking`, 
													`$moto_parking`, 
													`$delivery`, 
													`$wifi`, 
													`$description`, 
													`$public`, 
													`$delete`, 
													NOW(), 
													`$url_image`)");*/
													
		 $id = mysql_insert_id();
         // check if row inserted or not
         if ($result) {
             // successfully inserted into database
             $response["success"] = 1;
             $response["message"] = "Insert successfully created.";
			 $response["place_id"] = $id;
      
             // echoing JSON response
             echo json_encode($response);
         } else {
             // failed to insert row
             $response["success"] = 0;
             $response["message"] = "Oops! An error occurred.";
      
             // echoing JSON response
             echo json_encode($response);
         }
     } else {
         // required field is missing
         $response["success"] = 0;
         $response["message"] = "Required field(s) is missing";
      
         // echoing JSON response
         echo json_encode($response);
     }
 ?>